import menuSlice from '@/reducers/menuSlice';
import { AppDispatch } from "@/store";
import CommandBase from '@/core/command/base';
import { renderer } from '@/core/renderer';
import { useAppDispatch, useAppSelector } from '@/store';
import { Modal } from 'antd';


export default class CommandFileNew implements CommandBase{
  static Component: React.FC = () => {
    const dispatch = useAppDispatch()
    const fileNew = useAppSelector((state) => state.menus.fileNew)

    return <>
      <Modal 
        title='新建画布'
        open={fileNew.active} 
        closable={false}
        maskClosable={false}
        onOk={() => {
          dispatch(menuSlice.actions.setFileNew({
            active: false
          }))
        }} 
        onCancel={() => dispatch(menuSlice.actions.setFileNew({
          active: false
        }))}
      >
        
      </Modal>
    </>
  }

  constructor(){
  }

  static triggerCommand(dispatch: AppDispatch){
    dispatch(menuSlice.actions.setFileNew({
      active: true,
      form: {
        name: ''
      }
    }))
  }
}  